﻿/**
  @file		
  @brief	
  @author	
  @version	
*/
#pragma once

#include "../share/i_server.h"
#include "../share/platform/platform_thread.h"
#include "conn.h"

class CListenReadThread : public Thread
{
public:

	virtual U32 run();
};

class CWriteThread : public Thread
{
public:

	virtual U32 run();

};

class CServer : public IServer
{
protected:
	
	CConnection*	m_pConnectionArray;

	U16				m_u16ListenPort;

	U32				m_u32MaxClientsNum;

	U32				m_u32CurClientsNum;

	CListenReadThread*	m_pListenReadThread;

	CWriteThread*		m_pWriteThread;

#ifdef OS_WIN32
	HANDLE			m_hIOCP;
#else
	S32				m_s32EPollFD;
	
	S32				m_s32ListenSocket;
#endif

public:

	CServer( U32 u32MaxClientNum, U16 u16ListenPort );

	virtual ~CServer();

	virtual S32	StartService();
	
	virtual S32 StopService();
	
	virtual S32	DisconnectClient( U32 u32ClientIdx );

	virtual	S32 GetPackFromClient( U32 u32ClientIdx, U8*& pu8OutData, U32& u32OutDataSize );

	virtual S32 SendPackToClient( U32 u32ClientIdx, U8* pu8Data, U32 u32DataSize );


};
